#ifndef _PROTOCOL_H__
#define _PROTOCOL_H__
#include "mytype.h"

#define  BSIZE         1500
/*0xaa 0xlen 0xdest 0xsource 0xcmd 0xvalue 0xcrc 0x55*/
#define  MSGSIZE       9   

#define  PROTOCOL_HEAD  0xaa
#define  PROTOCOL_TAIL  0x55

#define BROADCAST_ADDR 0xfe
#define CMD_BROADCAST_WR_ID   0x10
 #define CMD_BROADCAST_SHOW_ID   0x20
#define CMD_BROADCAST_CLEAR_SHOW 0x30
#define CMD_BROADCAST_ENTER_BOOT 0x40
#define CMD_BROADCAST_CLEAR_HISTORY_DATA 0x50

#define CMD_SHOW_NUM   0x01
#define CMD_SHOW_REPLY_REQUST_NUM   0x02
#define CMD_SHOW_REPLY_NUM   0x02

#define CMD_PC_ACK_CLEAR_ORDER_DONE 0x03
#define REPLY_CMD_CLEAR_SHOW   0x23

extern CBuf       g_byteRxComBuf;
extern uint16     g_show_number;
extern uint16     g_pre_show_number;
extern uint32     g_flash_ID;
extern uint8      g_show_ID;
extern int        flag_wr_flash;
extern uint32      g_arrow_direction;

typedef struct protocol {   
	uint8 head;
	uint8 length;
	uint8 board_ID;
	uint8 reserve;
	uint8 cmd;
	uint8 value;
	uint8 checksum;
	uint8 tail;
}protocol_st, *p_protocol;

extern void queue_init(void);
extern BOOL queue_add_msg(pBuf MyBuf ,BYTE data );
extern BYTE queue_get_msg(pBuf MyBuf ,uint16 Pos);
extern BOOL queue_del_msg(pBuf MyBuf ,uint16 DelNum);
extern BOOL DecMsg( pBuf pMyBuf ,uint16 ndecodL);
void   send_master_procotol(uint8 cmd,uint16 data);
#endif
